require 'rubygems'
require 'cgi'
require 'dbi'
require 'uri'
require 'open-uri'
require 'dbaccess'
require 'sms_controller'

cgi = CGI.new

$config ||= YAML.load(File.open("config.yaml"))
$dbh ||= DBAccess.new($config)

$dbh.ensure_connection

data = { :body => cgi['body'], :msisdn => cgi['msisdn'], :smsc => cgi['smsc'], :charset => cgi['charset'] }

$dbh.save_inbox(data)

data[:body] =~ /^([-_\d\w]+)(.*)/i

command = $dbh.get_pattern($1) 

exit unless command

#puts command
#puts "ewan"

case command
  when 'grpmsg':
  when 'balance':
  when 'help':
    puts "testste"
end

